<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>新增项目</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/frame/layui/css/layui.css"  media="all">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>增加项目</legend>
</fieldset>
<form class="layui-form" action="" id="formId">
  <input type="button" class="layui-btn layui-btn-warm" style="float: right;  margin: 10px;" value="返回" onclick="goBack()">
  <input type="button" class="layui-btn layui-btn-normal" style="float: right; margin: 10px;" value="保存" onclick="addProject()">

<fieldset class="layui-elem-field" style="margin: 10px 10px 50px 10px; clear: both;">
 <legend>项目名</legend>
  <div class="layui-field-box">
    <div class="layui-input-block">
      <input type="text" name="project.projectName" lay-verify="title" autocomplete="off" placeholder="请输入项目名" class="layui-input">
    </div>
  </div>
  </fieldset>
  <fieldset class="layui-elem-field" style="margin: 10px 10px 50px 10px;">
   <legend>协议</legend>
  <div class="layui-field-box">
    <div class="layui-input-block">
      <input type="text" name="project.protocol" lay-verify="title" autocomplete="off" placeholder="请输入协议" class="layui-input">
    </div>
  </div>
  </fieldset>
  <fieldset class="layui-elem-field" style="margin: 10px 10px 50px 10px;">
   <legend>IP</legend>
  <div class="layui-field-box">
    <div class="layui-input-block">
      <input type="text" name="project.IP" lay-verify="title" autocomplete="off" placeholder="请输入IP" class="layui-input">
    </div>
  </div>
  </fieldset>
  <fieldset class="layui-elem-field" style="margin: 10px 10px 50px 10px;">
   <legend>端口号</legend>
  <div class="layui-field-box">
    <div class="layui-input-block">
      <input type="text" name="baseProject.port" lay-verify="title" autocomplete="off" placeholder="请输入端口号" class="layui-input">
    </div>
  </div>
  </fieldset>
  <fieldset class="layui-elem-field" style="margin: 10px 10px 50px 10px;">
   <legend>描述</legend>
  <div class="layui-field-box">
    <div class="layui-input-block">
      <textarea name="project.describe" placeholder="请输入描述内容" class="layui-textarea"></textarea>
    </div>
  </div>
  </fieldset>
  </form>
  <script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
  <script src="/frame/layui/lay/dest/layui.all.js" charset="utf-8"></script>
  <script type="text/javascript">
  function goBack(){
	  window.location.href="${basePath}/project/projectList";
  }
  function getFormParam(){
		return $("#formId").serialize();
	}
  function addProject(){
	 $.ajax({
	         type: "POST",
	         url: "${basePath}/project/addOrUpdateProject",
	         data: getFormParam(),
	         dataType: "json",
	         success: function(data){
	         	if(data.isSuccess){
	         		window.location.href="${basePath}/project/projectList";
	         	}else{
	         		layer.msg(data.message,{time: 3000});
	         	}
	         },
	         error: function(data){
	        	 layer.msg("网络错误！");
	         }
	     });

  }
  
  </script>
</body>
</html>